Today, hash functions are widely used in a variety of computing applications to map data in a larger set to a value in a smaller set. For example, a relatively long sequence of bits may be supplied as an input into a mathematical function to generate a shorter sequence of bits that serves as an index into a database table.
One area of application in which hashing can be particularly useful is network switching. In general, a network switch may receive and transmit data packets via multiple ports. In some situations, there may be more than one possible network link via which a packet can be transmitted to properly forward the data packet to its destination. Moreover, network links sometimes are purposefully aggregated to provide more bandwidth between communicating devices or networks. Grouping links together to define wider communication channels in the context of Layer-2 networking is sometimes referred to as link aggregation (LAG). In the context of Layer-3 networking, a routing technique typically referred to as equal-cost multi-path (ECMP) routing is utilized in situations where multiple paths present equally attractive routing choices to a network switch. Another Layer-2 network routing technique, referred to as weighted-cost multipath (WCMP) routing, may be utilized when different paths in a group exhibit unequal throughput rates.
A hash function is sometimes used to select one of the links or paths in a group of links/paths (e.g., a LAG group, an ECMP group, a WCMP group, a group of links/paths in a switch fabric, etc.) to transmit a packet. For example, the hash function can be applied to a portion or portions of a header of the packet, and a result of the hash function then indicates one of the links/paths in the group of links/paths via which the packet is to be transmitted.